{% extends 'base.html' %}
{% block title %}
    用户展示
{% endblock %}
{% block styles %}
    {{ super() }}
    <style>
        #add_article {
            width: 700px;
            text-align: center;
        }
    </style>
{% endblock %}
{% block scripts %}
    {{ super() }}
    <script src="/static/tinymce/tinymce.min.js"></script>
    <script>

        $(document).ready(function () {
            $(".user_center").hide();
            $("#user_show").show();
        });
        tinymce.init({
            selector: '#content',
            language: 'zh_CN'
        });

        function open_div(id) {
            $(".user_center").hide();
            $(id).show();
        }
    </script>
{% endblock %}
{% block newcontent %}
    <input type="button" class="btn btn-default" value="用户展示" onclick="open_div('#user_show')">
    <input type="button" class="btn btn-default" value="发表文章" onclick="open_div('#add_article')">
    <input type="button" class="btn btn-default" value="管理相册" onclick="open_div('#image')">
    <input type="button" class="btn btn-default" value="管理留言" onclick="open_div('#message')">
    <input type="button" class="btn btn-default" value="关于我设置" onclick="open_div('#about_me')">
    <div class="user_center" id="user_show">
        <table class="table table-striped">
            <tr>
                <td>序号</td>
                <td>用户名</td>
                <td>密码</td>
                <td>手机号</td>
                <td>邮箱</td>
                <td>注册时间</td>
                <td>操作</td>
            </tr>
            {% for user in users %}
                <tr>
                    <td>{{ loop.index }}</td>
                    <td>{{ user.username }}</td>
                    <td>{{ user.password }}</td>
                    <td>{{ user.phone }}</td>
                    <td>{{ user.email }}</td>
                    <td>{{ user.times }}</td>
                    <td><a href="{{ url_for('user.user_update') }}?uid={{ user.id }}">修改</a>
                        <a href="{{ url_for('user.user_delete') }}?uid={{ user.id }}">删除</a>
                    </td>
                </tr>
            {% endfor %}

        </table>
    </div>
    <div class="user_center col-md-offset-3" id="add_article">
        <form action="{{ url_for('article.article_publish') }}" method="post">
            <div class="form-group">
                <label for="title">文章标题</label>
                <input type="text" class="form-control" id="title" name="title" placeholder="文章标题">
            </div>
            <div class="form-group">
                <label for="article_type">文章类型</label>
                <select class="form-control" id="article_type" name="article_type">
                    <option value="0" disabled>请选择</option>
                    {% for article_type in article_types %}
                        <option value="{{ article_type.id }}"> {{ article_type.type }}</option>
                    {% endfor %}
                </select>
            </div>
            <label for="content">正文编辑</label>
            <textarea name="content" id="content"></textarea>
            <button type="submit" class="btn btn-default">发表文章</button>
        </form>
    </div>
    <div class="user_center col-md-offset-3" id="image">
        <form action="{{ url_for('article.photo_upload') }}" method="post" enctype="multipart/form-data">
        <div class="form-group">
                <label for="exampleInputFile">上传头像</label>
                <input type="file" id="exampleInputFile" name="photo">
            </div>
            <input type="submit" value="提交">
            </form>
    </div>
    <div class="user_center col-md-offset-3" id="message">
        管理留言
    </div>
    <div class="user_center col-md-offset-3" id="about_me">
        关于我设置
    </div>
{% endblock %}
